<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.location.bean.Userbean"%>
<%@page import="com.location.bean.LocateBean"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>



<% 
   ArrayList<Userbean> list = (ArrayList<Userbean>)request.getAttribute("location");
   String[][] longlat = new String[list.size()][7];
   Userbean user = null;
   LocateBean location = null;
   for(int i=0;i<list.size();i++){
		   user = list.get(i);
		   longlat[i][0] = user.getUmobilenum();
		   longlat[i][1] = user.getUname();
		   longlat[i][2] = user.getPmobile();
		   longlat[i][3] = user.getPname();
		   location = user.getLocation();
		   longlat[i][4] = location.getLongitude();
		   longlat[i][5] = location.getLatitude();
		   longlat[i][6] = location.getCreateDate();
   }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	 <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css" />
    <script src="http://cache.amap.com/lbs/static/es5.min.js"></script>
    <script src="http://webapi.amap.com/maps?v=1.3&key=您的密匙"></script>
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
  </head>
  
  <body>
     <div id="container"></div>

<script type="text/javascript">
    //初始化地图对象，加载地图
    var map = new AMap.Map("container", {resizeEnable: true});
  //  var lnglats = [
 //       [116.368904, 39.923423],
  //      [116.382122, 39.921176],
   //     [116.387271, 39.922501],
  //      [116.398258, 39.914600]
 //   ];
    var lnglats = new Array();
    <%
       for(int i=0;i<longlat.length;i++){
    %>
        lnglats[<%=i%>] = new Array();
        lnglats[<%=i%>][0] = <%=longlat[i][4]%>; 
    	lnglats[<%=i%>][1] = <%=longlat[i][5]%>;
    	 var marker = new AMap.Marker({
             position: lnglats[<%=i%>],
             map: map
         });
         marker.content = '用户名：'+'<%=longlat[i][1]%>'+'</br>'
                           +'手机号：'+'<%=longlat[i][0]%>'+'</br>'
                           +'监管人：'+'<%=longlat[i][3]%>'+'</br>'
                           +'监管人手机号:'+'<%=longlat[i][2]%>'+'</br>'
                           +'经度:'+'<%=longlat[i][4]%>'+'</br>'
                           +'纬度：'+'<%=longlat[i][5]%>'+'</br>'
                           +'时间：'+'<%=longlat[i][6]%>';
         marker.on('click', markerClick);
         marker.on('dblclick', markerClickDouble);
    <%}%>
    var infoWindow = new AMap.InfoWindow({ offset: new AMap.Pixel(0, -30) });


   // for (var i = 0, marker; i < lnglats.length; i++) {
   ///     var marker = new AMap.Marker({
   //         position: lnglats[i],
   //         map: map
    //    });
    //    marker.content = '桥梁第' + (i + 1) + '座';
    //    marker.on('click', markerClick);
   //     marker.on('dblclick', markerClickDouble);
        //  marker.emit('click', {target: marker});
   // }

    function markerClick(e) {
        infoWindow.setContent(e.target.content);
        infoWindow.open(map, e.target.getPosition());

      
    }

    function markerClickDouble(e) {
        alert(e.target.getPosition());
    }
    map.setFitView();
</script>
  </body>
</html>
